package com.uroad.jilinpda.util;

public enum GvApiResult {
    SUCCESS(0, "成功"),
    API_PARAMS_ERROR(4000, "接口参数错误"),

    READ_CONFIG_FILE_FAILED(4001, "读配置文件失败"),
    SAVE_CONFIG_FILE_FAILED(4002, "保存配置文件失败"),
    CONFIG_OBJ_IS_NULL(4003, "配置文件对象为空"),
    SAVE_FILE_CATCH_EXCEPTION(4004, "保存配置异常"),
    READ_FILE_CATCH_EXCEPTION(4005, "读取配置异常"),

    XML_TO_ENTITY_FAILED(4006, "XML字符串转换为Java对象失败"),
    ENTITY_TO_XML_FAILED(4007, "Java对象转换为XML字符串失败"),

    OPEN_DSRC_FAILED(4100, "打开天线设备失败"),
    CLOSE_DSRC_FAILED(4101, "关闭天线设备失败"),
    DSRC_USB_DISCONNECTED(4102, "未连接天线USB"),
    DSRC_USB_PERMISSION_DENIED(4103, "天线USB未授权"),
    SET_DSRC_FAILED(4104, "设置天线设备失败"),
    SEND_COS_TO_DSRC_FAILED(4105, "发送COS指令至天线模块失败,请退出后重试"),
    DSRC_EXEC_COS_FAILED(4106, "执行COS指令失败"),
    COS_RSP_SW_ERROR(4107, "COS返回非9000状态码"),
    JUDGE_COS_RSP_STATUS_CATCH_EXCEPTION(4108, "判断COS结果异常"),
    ETC_MODULE_RESET_FAILED(4109, "ETC/CPC卡复位失败，请检查卡片是否放好"),
    GET_VEH_SECURE_FAILED(4110, "获取车辆信息密文失败"),
    READ_VEH_CHECK_MAC_FAILED(4111, "读取车辆信息校验MAC失败"),
    OBU_NO_FIND(4112, "没有搜索到标签"),
    CARD_RESET_FAILED(4113, "卡片复位失败，请检查卡片是否放好"),
    CARD_INSUFFICIENT_BALANCE(4114, "卡片余额不足"),
    CARD_BALANCE_NO_CHANGE(4115, "卡片余额没有变化"),
    PSAM_CALC_3DES_FAILED(4116, "PSAM计算3DES失败"),
    CARD_CHECK_MAC1_FAILED(4117, "比较MAC1失败，请稍后重试"),
    CARD_CREDIT_INIT_FAILED(4118, "卡片圈存初始化失败"),
    CARD_NO_FIND(4119, "未检测到卡片"),
    OBU_OR_CPC_NO_FIND(4120, "没有搜索到标签或CPC卡"),

    CONN_TO_CLOUD_BOX_FAILED(4121, "连接云盒失败"),
    CLOUD_BOX_ENTER_DIR_FAILED(4122, "进入云盒目录失败"),
    CLOUD_BOX_DIV_KEY_FAILED(4123, "进入云盒分散密钥失败"),
    READ_OBU_ENCODE_VEH_INFO_FAILED(4123, "读取标签车辆信息密文失败"),
    CLOUD_BOX_DECODE_VEH_INFO_FAILED(4124, "云盒解密标签车辆信息密文失败"),
    CLOUD_BOX_GET_PSAM_TERMINATEID_FAILED(4125, "获取云盒终端机编号失败"),
    CLOUD_BOX_CALC_COMSUME_MAC_FAILED(4126, "云盒计算消费MAC失败"),

    SM4_DIV_KEY_FAILED(4127, "SM4分散密钥失败"),
    CPC_BATTRY_LOW(4128, "电量低,请更换CPC卡"),

    UNKNOWN_ERROR(5000, "未知错误"),
    CATCH_EXCEPTION(5001, "执行异常"),
    USB_DISCONNECTED(5002, "DSRC天线模块USB未连接"),
    USB_PERMISSION_DENIED(5003, "DSRC天线模块USB未授权"),



    //COS结果状态码
    COS_SW_6100(0x6100, "需发GET RESPONSE命令"),
    COS_SW_6200(0x6200, "信息未提供"),
    COS_SW_6281(0x6281, "回送数据可能出错"),
    COS_SW_6282(0x6282, "文件长度小于Le"),
    COS_SW_6283(0x6283, "选中的文件无效，文件或密钥校验错误"),
    COS_SW_6284(0x6284, "FCI格式与P2指定的不符"),
    COS_SW_6300(0x6300, "鉴别失败"),
    COS_SW_63C0(0x63C0, "校验失败,（0－允许重试次数）"),
    COS_SW_63C1(0x63C1, "校验失败,（1－允许重试次数）"),
    COS_SW_63C2(0x63C2, "校验失败,（2－允许重试次数）"),
    COS_SW_63C3(0x63C3, "校验失败,（3－允许重试次数）"),
    COS_SW_63C4(0x63C4, "校验失败,（4－允许重试次数）"),
    COS_SW_63C5(0x63C5, "校验失败,（5－允许重试次数）"),
    COS_SW_63C6(0x63C6, "校验失败,（6－允许重试次数）"),
    COS_SW_63C7(0x63C7, "校验失败,（7－允许重试次数）"),
    COS_SW_63C8(0x63C8, "校验失败,（8－允许重试次数）"),
    COS_SW_63C9(0x63C9, "校验失败,（9－允许重试次数）"),
    COS_SW_63CA(0x63CA, "校验失败,（10－允许重试次数）"),
    COS_SW_63CB(0x63CB, "校验失败,（11－允许重试次数）"),
    COS_SW_63CC(0x63CC, "校验失败,（12－允许重试次数）"),
    COS_SW_63CD(0x63CD, "校验失败,（13－允许重试次数）"),
    COS_SW_63CE(0x63CE, "校验失败,（14－允许重试次数）"),
    COS_SW_63CF(0x63CF, "校验失败,（15－允许重试次数）"),
    COS_SW_6400(0x6400, "状态标志位没有变"),
    COS_SW_6581(0x6581, "内存失败,写EEPROM失败"),
    COS_SW_6600(0x6600, "接收通讯超时"),
    COS_SW_6601(0x6601, "接收字符奇偶错"),
    COS_SW_6602(0x6602, "校验和不对"),
    COS_SW_6603(0x6603, "当前DF文件无FCI"),
    COS_SW_6604(0x6604, "当前DF下无SF或KF"),
    COS_SW_6700(0x6700, "长度错误"),
    COS_SW_6882(0x6882, "不支持安全报文"),
    COS_SW_6900(0x6900, "不能处理"),
    COS_SW_6901(0x6901, "命令不接受（无效状态）"),
    COS_SW_6981(0x6981, "命令与文件结构不相容，当前文件非所需文件"),
    COS_SW_6982(0x6982, "操作条件（AC）不满足，没有校验PIN"),
    COS_SW_6983(0x6983, "认证方法锁定，PIN被锁定"),
    COS_SW_6984(0x6984, "随机数无效，引用的数据无效"),
    COS_SW_6985(0x6985, "使用条件不满足"),
    COS_SW_6986(0x6986, "不满足命令执行条件（不允许的命令，INS有错）"),
    COS_SW_6987(0x6987, "MAC丢失"),
    COS_SW_6988(0x6988, "MAC不正确"),
    COS_SW_698D(0x698D, "保留状态码，未定义"),
    COS_SW_6A80(0x6A80, "数据域参数不正确"),
    COS_SW_6A81(0x6A81, "功能不支持；创建不允许；目录无效；应用锁定"),
    COS_SW_6A82(0x6A82, "该文件未找到"),
    COS_SW_6A83(0x6A83, "该记录未找到"),
    COS_SW_6A84(0x6A84, "文件预留空间不足"),
    COS_SW_6A86(0x6A86, "P1或P2不正确"),
    COS_SW_6A88(0x6A88, "引用数据未找到"),
    COS_SW_6B00(0x6B00, "参数错误"),
    COS_SW_6C00(0x6C00, "Le长度错误"), //实际可能为0x6CXX，实际长度是XX
    COS_SW_6D00(0x6D00, "不支持的指令代码"),
    COS_SW_6E00(0x6E00, "不支持的类：CLA有错"),
    COS_SW_6F00(0x6F00, "数据无效"),
    COS_SW_9301(0x9301, "资金不足"),
    COS_SW_9302(0x9302, "MAC无效"),
    COS_SW_9303(0x9303, "应用被永久锁定"),
    COS_SW_9401(0x9401, "交易金额不足"),
    COS_SW_9402(0x9402, "交易计数器达到最大值"),
    COS_SW_9403(0x9403, "密钥索引不支持"),
    COS_SW_9406(0x9406, "所需MAC不可用");


    private int code;
    private String msg;

    GvApiResult(int code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public int getCode() {
        return code;
    }

    public String getMsg() {
        return msg;
    }

    public static GvApiResult valueOf(int value) {
        switch (value) {
            case 0x6200:
                return COS_SW_6200;
            case 0x6281:
                return COS_SW_6281;
            case 0x6282:
                return COS_SW_6282;
            case 0x6283:
                return COS_SW_6283;
            case 0x6988:
                return COS_SW_6988;
            case 0x9303:
                return COS_SW_9303;
            default:
                return COS_RSP_SW_ERROR;
        }


    }

}
